<template>
	<view class="container">
		<view v-if="res">
			<view class="title">{{res.title}}</view>
			<view class="date">{{ formatDate(res.executionTime)}}</view>
			<!-- <rich-text class="content">{{res.content}}</rich-text> -->
			<view class="content">
				<u-parse :content="res.content"></u-parse>
			</view>
		</view>
		<view class="" v-else>
			<u-empty mode="car" :marginTop="50" text="暂无数据" icon="/static/images/common/empty.png"></u-empty>
		</view>
	</view>

	</view>
</template>

<script>
	import {
		getAgreement
	} from '@/api/user.js'

	export default {
		data() {
			return {
				res: null,
			}
		},
		onLoad() {

		},
		onShow() {
			this._getAgreement()
		},
		methods: {
			formatDate(dataStr) {
				const date = new Date(dataStr);
				if (!isNaN(date)) {
					const year = date.getFullYear();
					const month = String(date.getMonth() + 1).padStart(2, '0');
					const day = String(date.getDate()).padStart(2, '0');
					const hours = String(date.getHours()).padStart(2, '0');
					const minutes = String(date.getMinutes()).padStart(2, '0');
					const seconds = String(date.getSeconds()).padStart(2, '0');
					return `${year}年${month}月${day}日`;
					// return `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`;
				} else {
					// 无法解析日期，返回原始字符串或抛出错误，取决于需求
					return dataStr;
				}
			},
			_getAgreement() {
				let _that = this
				getAgreement("2").then(res => {
					console.log(res);
					_that.res = res.data
				})
			}
		}
	}
</script>

<style lang="scss">
	.container {
		padding: 22px 16px;

		.title {
			text-align: center;
			height: 28px;
			font-size: 18px;
			font-family: PingFangSC, PingFang SC;
			font-weight: 600;
			color: #3A3D4B;
			line-height: 28px;
		}

		.date {
			margin-top: 10px;
		}

		.content {
			margin-top: 10px;
			font-size: 14px;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			color: #3A3D4B;
			line-height: 22px;
		}
	}
</style>